<?php

class DefaultController extends Controller
{
        public function accessRules()
    {
        return array(
            array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('index'),
                'users'=>array('@'),
            ),
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('admin','delete'),
                'users'=>array('admin'),
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }
	public function actionIndex($id)
	{
		$jobtype = Jobtype::model()->findAll();
        $budget = Budget::model()->findAll();
        $dataProvider=new CActiveDataProvider('Job',array(
            'pagination'=>array(
                'pageSize'=>3,
            ),
            'criteria'=> array(
                'with'=>array('subjobtype'),
                'condition' => 'subjobtype.id=:subjob',
                'params' => array(':subjob'=>$id)
            )
        ));
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
            'jobtype'=>$jobtype,
            'budget'=> $budget,
		));
	}
    public function actionView($id)
	{
		$model = new CActiveDataProvider('Job',array(
            'pagination'=>array(
                'pageSize'=>3,
            ),
            'criteria'=> array(
                'with'=>array('budget')
            )
        ));
		$this->render('view',array(
			'model'=>$model
		));
	}
    public function actionSearch(){

        if (isset($_GET['name'])) {
            echo 'aaa';
        }
    }
}